ga.view.examples.simple
Class SimpleObjectIndividual

java.lang.Object
  extended by ga.view.examples.simple.SimpleObjectIndividual
All Implemented Interfaces:
IAge, IAgeIndividual<SimpleObjectIndividual>, IFitness, IIndividual<SimpleObjectIndividual>, java.lang.Cloneable

public final class SimpleObjectIndividual
extends java.lang.Object
implements IAgeIndividual<SimpleObjectIndividual>, IFitness

Individual for the simple object example.

Since:
12.08.2012
Author:
Stephan Dreyer

Field Summary
private  int age
           
private  double fitness
           
private  java.util.List<java.lang.Number> genotype
           
private  long id
           
private static java.util.concurrent.atomic.AtomicLong ID_GENERATOR
           
private  int maxAge
           
static int NUM_PARAMETERS
           
static int PARAMETER_TYPE
           
static int PARAMETERS_COLOR
           
private static java.util.Random RND
           
static int TYPE_COUNT
           
 
Fields inherited from interface ga.core.individual.IFitness
UNEVALUATED
 
Constructor Summary
SimpleObjectIndividual()
          Instantiates a new simple object individual.
 
Method Summary
 SimpleObjectIndividual clone()
          Creates a new individual that is equal to this.
 int getAge()
          Getter for the age.
 float getAgeNormalized()
          Getter for the normalized age (in [0;1]).
 GAContext getContext()
          Getter for the GA context.
 double getFitness()
          Getter for the fitness of the individual.
 java.util.List<java.lang.Number> getGenotype()
          Gets the genotype.
 long getId()
          Getter for the unique id.
 int getMaxAge()
          Gets the maximum age.
 void incAge()
          Increments the age.
 void initRandomly()
          Initializes the genotype randomly and resets the fitness.
 boolean isEvaluated()
          Determines if the individual has been evaluated.
 boolean isOld()
          Determines if the individual is too old and should die.
 void setContext(GAContext context)
          Sets the GA context.
 void setFitness(double fitness)
          Setter for the fitness of the individual.
 void setMaxAge(int maxAge)
          Setter for the maximum age.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TYPE_COUNT

public static final int TYPE_COUNT
See Also:
Constant Field Values

PARAMETERS_COLOR

public static final int PARAMETERS_COLOR
See Also:
Constant Field Values

PARAMETER_TYPE

public static final int PARAMETER_TYPE
See Also:
Constant Field Values

NUM_PARAMETERS

public static final int NUM_PARAMETERS
See Also:
Constant Field Values

RND

private static final java.util.Random RND

ID_GENERATOR

private static final java.util.concurrent.atomic.AtomicLong ID_GENERATOR

id

private final long id

maxAge

private int maxAge

genotype

private final java.util.List<java.lang.Number> genotype

age

private int age

fitness

private double fitness
Constructor Detail

SimpleObjectIndividual

public SimpleObjectIndividual()
Instantiates a new simple object individual.

Since:
12.08.2012
Method Detail

getId

public long getId()
Description copied from interface: IIndividual
Getter for the unique id.

Specified by:
getId in interface IIndividual<SimpleObjectIndividual>
Returns:
The id.

setContext

public void setContext(GAContext context)
Description copied from interface: IIndividual
Sets the GA context.

Specified by:
setContext in interface IIndividual<SimpleObjectIndividual>
Parameters:
context - The context

getContext

public GAContext getContext()
Description copied from interface: IIndividual
Getter for the GA context.

Specified by:
getContext in interface IIndividual<SimpleObjectIndividual>
Returns:
context The context

initRandomly

public void initRandomly()
Description copied from interface: IIndividual
Initializes the genotype randomly and resets the fitness.

Specified by:
initRandomly in interface IIndividual<SimpleObjectIndividual>

setFitness

public void setFitness(double fitness)
Description copied from interface: IFitness
Setter for the fitness of the individual.

Specified by:
setFitness in interface IFitness
Parameters:
fitness - The fitness.

getFitness

public double getFitness()
Description copied from interface: IFitness
Getter for the fitness of the individual.

Specified by:
getFitness in interface IFitness
Returns:
The fitness.

getGenotype

public java.util.List<java.lang.Number> getGenotype()
Gets the genotype.

Returns:
the genotype
Since:
12.08.2012

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getAge

public int getAge()
Description copied from interface: IAge
Getter for the age.

Specified by:
getAge in interface IAge
Returns:
The age.

setMaxAge

public void setMaxAge(int maxAge)
Description copied from interface: IAge
Setter for the maximum age.

Specified by:
setMaxAge in interface IAge
Parameters:
maxAge - The maximum age

getAgeNormalized

public float getAgeNormalized()
Description copied from interface: IAge
Getter for the normalized age (in [0;1]).

Specified by:
getAgeNormalized in interface IAge
Returns:
The normalized age.

isOld

public boolean isOld()
Description copied from interface: IAge
Determines if the individual is too old and should die.

Specified by:
isOld in interface IAge
Returns:
Old

getMaxAge

public int getMaxAge()
Gets the maximum age.

Returns:
the max age
Since:
12.08.2012

incAge

public void incAge()
Description copied from interface: IAge
Increments the age.

Specified by:
incAge in interface IAge

isEvaluated

public boolean isEvaluated()
Description copied from interface: IIndividual
Determines if the individual has been evaluated.

Specified by:
isEvaluated in interface IIndividual<SimpleObjectIndividual>
Returns:
true if the individual is evaluated.

clone

public SimpleObjectIndividual clone()
Description copied from interface: IIndividual
Creates a new individual that is equal to this.

Specified by:
clone in interface IIndividual<SimpleObjectIndividual>
Overrides:
clone in class java.lang.Object
Returns:
The clone.